{{define "address"}}
<div class="wrapper">
    <div class="row">
  <div class="col-xs-15 col-md-8 col-lg-8 notication-col center-block">
    {{range .Flash}}<div class="well well-notification orange-notification">{{.}}</div>{{end}}
  </div>
    <div class="col-sm-15 col-md-10 text-left center-block">
       <h1>{{if .User.MultiSigAddress }}Address Submitted{{else}}Submit Address{{end}}</h1>
     <p><strong>When you submit an address, the voting service binds that address
        from your wallet together with an address from the voting service's voting
        wallet.  This is done by creating a 1-of-2 multisignature script which
        lets you, the voting service, or both parties vote.  This "binding" of the wallets
        means that if you ever delete your current wallet and create a new
        wallet with a different seed, importing your multisignature script will
        not work because it contains an address that is not present in your new
        wallet.  Please contact your voting service administrator or support staff
        if you need to re-register with a new address from a new wallet.</strong></p>
{{if .User.MultiSigAddress}}
     <div style="overflow:auto">
        <p><span style="font-size: larger;"><strong>Your public key address has
        been accepted and registration is complete.  Please contact your stake
        pool administrator or support staff if you need to re-register with a
        new address from a new wallet.</strong></span></p>
        <p><strong>Public Key Address:</strong> &nbsp;<strong>{{ .User.UserPubKeyAddr }}</strong></p>
        <p><strong>If you wish to verify that this address belongs to your
        wallet, you may run the following command:</strong></p>
        <div class="cmd"><pre>
$ dcrctl {{ if eq .Network "testnet"}}--testnet{{end}} --wallet validateaddress {{ .User.UserPubKeyAddr }}
        </pre></div>
        <p><strong>In the result, you will see fields such as "ismine" and
        "account" if the address is present.</strong></p>
     </div>
{{ else }}
        <p><strong>The official Decred GUI wallet
        <a href="https://decred.org/downloads/#decrediton">Decrediton</a>
        is the recommended way to use voting services.  All you need to get started
        is to copy and paste the API Token from the <a href="/settings">Settings Page</a>.  A more
        comprehensive guide is available for
        <a href="https://docs.decred.org/getting-started/user-guides/decrediton-setup/">Decrediton</a>.
	There is also a more general overview of the staking process available
	<a href="https://docs.decred.org/mining/proof-of-stake/#automatic-purchasing-of-tickets" target="_blank" rel="noopener noreferrer">here</a>.</strong></p>
	<p><strong>It is recommended to use the latest versions of the Decred software before starting.&nbsp;</strong>
	<a href="https://decred.org/downloads/" target="_blank" rel="noopener noreferrer"><span aria-label="Decred Downloads Page"> &#8675; Decred Downloads Page</span></a>
	</p>

        <p>The directions below require that you
        have setup the Decred software and have obtained Decred that you can
        purchase tickets with.  The
        <a href="https://docs.decred.org/getting-started/beginner-guide/">Getting Started</a>
        section of the <a href="https://docs.decred.org/">Decred Docs website</a>
        has operating system specific directions that covers all of the necessary
        steps.  The <a href="https://docs.decred.org/getting-started/user-guides/dcrwallet-tickets/">dcrwallet instructions</a>
        are the most helpful if you wish to continue on the command-line path.</p>
        <p>To join the voting service, provide a public key
        address which will be used to generate a 1-of-2 multisignature script.
        The multisignature script will be generated by the service and returned to you
        along with a P2SH address to give voting rights to. The P2SH address has the
        prefix
        <b>{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}c</b>.</p>

        <p>To generate a public key address, create
        a new wallet address with <b>getnewaddress</b>. Then,
        call <b>validateaddress &lt;yourAddress&gt;</b> and retrieve the address
        listed in the <b>pubkeyaddr</b> field of the response. The <b>pubkeyaddr</b>
        starts with
        <b>{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}k</b>.</p>

        <p>The following is an example:</p>

        <div class="cmd"><pre>
$ dcrctl {{ if eq .Network "testnet"}}--testnet{{end}} --wallet getnewaddress
{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}sExampleAddr1For2Demo3PurposesOnly
$ dcrctl {{ if eq .Network "testnet"}}--testnet{{end}} --wallet validateaddress {{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}sExampleAddr1For2Demo3PurposesOnly
{
  "isvalid": true,
  "address": "{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}sExampleAddr1For2Demo3PurposesOnly",
  "ismine": true,
  "pubkeyaddr": <b>"{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}kExample0Addr1For2Demo4Purposes5Only6Do7Not8Use9Pls0"</b>,
  "pubkey": "022801337beefc0ffee1dab8d4ffa898a782466c9a1fc00ca8863de5438dc07dcc",
  "iscompressed": true,
  "account": "default"
}
        </pre></div>

        <p>Copy and paste the <b>pubkeyaddr</b>
        that starts with
        <b>{{ if eq .Network "mainnet"}}D{{end}}{{ if eq .Network "testnet"}}T{{end}}k</b>
        into the form below. If the registration process is successful, then
        instructions will be given on how to purchase tickets that the voting service and
        yourself can vote with when called upon to do so by the network.</p>

                <form method="post" class="form-horizontal">
                        <div class="form-group">
                                <label class="control-label col-sm-3" for="UserPubKeyAddr">Public Key Address: &nbsp;</label>
				<div class="col-sm-12">
                                <input id="UserPubKeyAddr" name="UserPubKeyAddr" type="text" placeholder="Enter Address" class="form-control" minlength=40 maxlength=65 required="required" size=60> &nbsp;
				</div>
			</div>
			<div class="form-group">
                                <button id="signup" name="signup" class="btn btn-primary">Submit Address</button>
                        </div>
                <input type="hidden" name="{{.CsrfKey}}" value={{.CsrfToken}}>
                </form>
{{ end }}
    </div>
    </div>
        {{if not .User}}
     <div class="row row-button">
      <div class="col-sm-15 col-md-6 center-block text-center">
        <button type="button" class="btn btn-primary" id="btn-sign-up" ><a href="#">Sign up</a></button>
      </div>
    </div>
        {{end}}
</div>
{{end}}
